home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / distutils / command / bdist_dumb.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  4.5 KB  |  98 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''distutils.command.bdist_dumb
  5.  
  6. Implements the Distutils \'bdist_dumb\' command (create a "dumb" built
  7. distribution -- i.e., just an archive to be unpacked under $prefix or
  8. $exec_prefix).'''
  9. __revision__ = '$Id: bdist_dumb.py 61000 2008-02-23 17:40:11Z christian.heimes $'
  10. import os
  11. from distutils.core import Command
  12. from distutils.util import get_platform
  13. from distutils.dir_util import remove_tree, ensure_relative
  14. from distutils.errors import *
  15. from distutils.sysconfig import get_python_version
  16. from distutils import log
  17.  
  18. class bdist_dumb(Command):
  19.     description = 'create a "dumb" built distribution'
  20.     user_options = [
  21.         ('bdist-dir=', 'd', 'temporary directory for creating the distribution'),
  22.         ('plat-name=', 'p', 'platform name to embed in generated filenames (default: %s)' % get_platform()),
  23.         ('format=', 'f', 'archive format to create (tar, ztar, gztar, zip)'),
  24.         ('keep-temp', 'k', 'keep the pseudo-installation tree around after ' + 'creating the distribution archive'),
  25.         ('dist-dir=', 'd', 'directory to put final built distributions in'),
  26.         ('skip-build', None, 'skip rebuilding everything (for testing/debugging)'),
  27.         ('relative', None, 'build the archive using relative paths(default: false)')]
  28.     boolean_options = [
  29.         'keep-temp',
  30.         'skip-build',
  31.         'relative']
  32.     default_format = {
  33.         'posix': 'gztar',
  34.         'nt': 'zip',
  35.         'os2': 'zip' }
  36.     
  37.     def initialize_options(self):
  38.         self.bdist_dir = None
  39.         self.plat_name = None
  40.         self.format = None
  41.         self.keep_temp = 0
  42.         self.dist_dir = None
  43.         self.skip_build = 0
  44.         self.relative = 0
  45.  
  46.     
  47.     def finalize_options(self):
  48.         if self.bdist_dir is None:
  49.             bdist_base = self.get_finalized_command('bdist').bdist_base
  50.             self.bdist_dir = os.path.join(bdist_base, 'dumb')
  51.         
  52.         if self.format is None:
  53.             
  54.             try:
  55.                 self.format = self.default_format[os.name]
  56.             except KeyError:
  57.                 raise DistutilsPlatformError, ("don't know how to create dumb built distributions " + 'on platform %s') % os.name
  58.             except:
  59.                 None<EXCEPTION MATCH>KeyError
  60.             
  61.  
  62.         None<EXCEPTION MATCH>KeyError
  63.         self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'), ('plat_name', 'plat_name'))
  64.  
  65.     
  66.     def run(self):
  67.         if not self.skip_build:
  68.             self.run_command('build')
  69.         
  70.         install = self.reinitialize_command('install', reinit_subcommands = 1)
  71.         install.root = self.bdist_dir
  72.         install.skip_build = self.skip_build
  73.         install.warn_dir = 0
  74.         log.info('installing to %s' % self.bdist_dir)
  75.         self.run_command('install')
  76.         archive_basename = '%s.%s' % (self.distribution.get_fullname(), self.plat_name)
  77.         if os.name == 'os2':
  78.             archive_basename = archive_basename.replace(':', '-')
  79.         
  80.         pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
  81.         if not self.relative:
  82.             archive_root = self.bdist_dir
  83.         elif self.distribution.has_ext_modules() and install.install_base != install.install_platbase:
  84.             raise DistutilsPlatformError, "can't make a dumb built distribution where base and platbase are different (%s, %s)" % (repr(install.install_base), repr(install.install_platbase))
  85.         else:
  86.             archive_root = os.path.join(self.bdist_dir, ensure_relative(install.install_base))
  87.         filename = self.make_archive(pseudoinstall_root, self.format, root_dir = archive_root)
  88.         if self.distribution.has_ext_modules():
  89.             pyversion = get_python_version()
  90.         else:
  91.             pyversion = 'any'
  92.         self.distribution.dist_files.append(('bdist_dumb', pyversion, filename))
  93.         if not self.keep_temp:
  94.             remove_tree(self.bdist_dir, dry_run = self.dry_run)
  95.         
  96.  
  97.  
  98.